package demo1;

public class TestDemo1 {
    //实现多态
    public static void eat(Animal animal) {
        animal.eat();
    }

    public static void main(String[] args) {
        //new Animal("阿黄",1);//不能实例化抽象类

        Dog dog = new Dog("阿黄",1);
        Cat cat = new Cat("小黑",2);

        eat(dog);
        eat(cat);

        System.out.println("========");

        Animal[] animal = new Animal[]{dog, cat};//向上转型
        for (Animal a:animal) {
            a.eat();
        }
    }
}
